package cn.mesmile.nacos.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author zb
 * @date 2020/12/18 16:30
 * @Description                             @RefreshScope  动态刷新配置
 */
@RestController
@RequestMapping("/api/v1/nacos")
@RefreshScope
public class NacosController {

    @Value("${useLocalCache:false}")
    private boolean useLocalCache;

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/get")
    public boolean get() {
        return useLocalCache;
    }

    @GetMapping("/info")
    public Object getInfo(){
        Object forObject = restTemplate.getForObject("http://xdclass-seata-order/api/v1/order/getProduct", Object.class);
        return forObject;
    }
}
